<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Canvas Incremental Repaint</title>
  <style type="text/css" media="screen">
    canvas {
      width: 300px;
      height: 300px;
      border: 20px solid green;
      padding: 10px;
      background-color: green;
    }
  </style>
  <script src="../../resources/run-after-layout-and-paint.js"></script>
  <script type="text/javascript" charset="utf-8">

    if (window.testRunner)
      testRunner.waitUntilDone();

    var canvas;
    var ctx;

    function beginTest()
    {
      canvas = document.getElementById('canvas1');
      ctx = canvas.getContext('2d');
      canvas.width = 300;
      canvas.height = 300;
      ctx.fillStyle = 'red';
      ctx.fillRect(0, 0, 300, 300);
      runAfterLayoutAndPaint(repaintTest)
    }

    function repaintTest()
    {
      ctx.fillStyle = 'green';
      ctx.fillRect(0, 0, 300, 300);
      if (window.testRunner) {
          testRunner.notifyDone();
      }
    }    
  </script>
</head>
<body onload="beginTest()">
  <p>Expect a solid green square below this text.</p>
  <canvas id="canvas1"></canvas>
</body>
</html>
